package com.mxcyk.serviceLogic;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;

import com.uujava.minibox.ui.button.ImageJButton;

/**
 * 功能：用来监听GUI的Line类的动作
 * @author k 2012-8-5
 *
 */
public class GetAction implements ActionListener,MouseListener{
	ArrayList<Appfile> appf;//调用列表
	Run run = Run.getRun();// 程序执行类
	public ArrayList<Appfile> getAppf() {
		return appf;
	}

	public void setAppf(ArrayList<Appfile> appf) {
		this.appf = appf;
	}

	public GetAction(ArrayList<Appfile> applist){
		this.appf=applist;
	}
	

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		/**
		 * 可以通过： ((JLabel)arg0.getSource()).getName()获得控件的名字
		 * 可以通过这个名字标记来判断是那个控件是属于那个 卡片即JLabel字符数组下标
		 * 即((JLabel)arg0.getSource()).getName()=卡片编号+" "+下标；
		 * 
		 */
//		
		if (e.getClickCount() == 1) {
			String str = ((ImageJButton) e.getSource()).getName();// 得到的名字
			int index = Integer.parseInt((String) str.subSequence(str
					.lastIndexOf(' ') + 1, str.length()));// 获得数组下标
			System.out.println("GetAction类获得需执行的应用下标为："+index);
			File file = appf.get(index).getAppPath();
			run.runSuffix(file);// 运行程序

		}
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}
